home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1-sources / sources / kbd-patch / text.c < prev   
Encoding:
C/C++ Source or Header  |  1994-05-23  |  1.6 KB  |  61 lines  |  [TEXT/EMAC]

  1. /*
  2.  * Copyright (C) 1994 Marc Parmet.
  3.  * This file is part of the Macintosh port of GNU Emacs.
  4.  *
  5.  * GNU Emacs is distributed in the hope that it will be useful,
  6.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8.  * GNU General Public License for more details.
  9.  */
  10.  
  11. #include <Types.h>
  12. #include <Processes.h>
  13. #include <MixedMode.h>
  14. #include "emacs-version.h"
  15. #include "kbd-patch-data.h"
  16.  
  17. pascal long
  18. emacs_KeyTrans_patch(Ptr transData,short keyCode,long *state)
  19. {
  20.     int i,size;
  21.     Boolean same;
  22.     short err,modifiers;
  23.     ProcessSerialNumber front_psn;
  24.     struct keyboard_patch_vector *v;
  25.     struct keyboard_patch_data *kbpd;
  26.  
  27.     kbpd = (struct keyboard_patch_data *)PATCH_MAGIC;
  28.  
  29.     if (kbpd->emacs_psn.lowLongOfPSN != 0 || kbpd->emacs_psn.highLongOfPSN != 0) {
  30.         err = GetFrontProcess(&front_psn);
  31.         if (!err) {
  32.             err = SameProcess(&kbpd->emacs_psn,&front_psn,&same);
  33.             if (!err && same) {
  34.                 v = MODIFIER_XVECTOR(*kbpd->v);
  35.                 if (v != 0L) {
  36.                     modifiers = keyCode & MODIFIER_KEYS;
  37.                     if (modifiers != 0) {
  38.                         /* Clear the mark bit, so this doesn't crash during gc. */
  39.                         size = v->size & 0x7fffffff;
  40.                         for (i = 0; i<size; ++i) {
  41.                             if (v->contents[i].typed == modifiers) {
  42.                                 keyCode &= ~MODIFIER_KEYS;
  43.                                 keyCode |= v->contents[i].denoted &
  44.                                     ~(controlKey | metaKey);
  45.                                 break;
  46.                             }
  47.                         }
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.     }
  53.     
  54. #if defined(powerc)
  55.     return CallUniversalProc(kbpd->original,uppKeyTransProcInfo,
  56.                              transData,keyCode,state);
  57. #else
  58.     return (*(KeyTransProcPtr)kbpd->original)(transData,keyCode,state);
  59. #endif
  60. }
  61.